import request from '@/utils/request'

// 查询仓库列表
export function listStorehouse(query) {
  return request({
    url: '/basic/storehouse/list',
    method: 'get',
    params: query
  })
}
// 查询仓库对应物料的可用数量
export function getAvailableQty(query) {
  return request({
    url: '/inOutStock/outStockDetailOrder/availableQty',
    method: 'get',
    params: query
  })
}

// 查询仓库详细
export function getStorehouse(id) {
  return request({
    url: '/basic/storehouse/' + id,
    method: 'get'
  })
}
// 根据物料编号查询仓库
export function getStorehouseListByProductNo(productNo) {
  return request({
    url: '/basic/storehouse/listByProductNo/' + productNo,
    method: 'get'
  })
}

// 新增仓库
export function addStorehouse(data) {
  return request({
    url: '/basic/storehouse',
    method: 'post',
    data: data
  })
}

// 修改仓库
export function updateStorehouse(data) {
  return request({
    url: '/basic/storehouse',
    method: 'put',
    data: data
  })
}

// 删除仓库
export function delStorehouse(id) {
  return request({
    url: '/basic/storehouse/' + id,
    method: 'delete'
  })
}

// 查询仓库权限列表
export function listStorehousePermission(query) {
  return request({
    url: '/basic/storehousePermission/list',
    method: 'get',
    params: query
  })
}

// 查询仓库列表
export function selectionList(query) {
  return request({
    url: '/basic/storehouse/selectionList',
    method: 'get',
    params: query
  })
}


/** 绘制拣货库区和拣货库位 **/ 
// 左侧以“树”结构展示仓库，库区，库位信息
export function selectStoreHouseByTree(params) {
  return request({
    url: '/basic/storehousePlat/selectStoreHouseByTree/'+ params,
    method: 'get',
  })
}
// 获取仓库背景及其库区元素信息
export function getInfoByStorehouseNo(storehouseNo) {
  return request({
    url: '/basic/storehousePlat/getInfoByStorehouseNo/' + storehouseNo,
    method: 'get'
  })
}
// 获取库区背景及其库位元素信息
export function getInfoByStorehouseAreaNo(storehouseAreaNo) {
  return request({
    url: '/basic/storehouseAreaPlat/getInfoByStorehouseAreaNo/' + storehouseAreaNo,
    method: 'get'
  })
}

// 编辑仓库下库区信息
export function putStorehousePlat(data) {
  return request({
    url: '/basic/storehousePlat',
    method: 'put',
    data
  })
}
// 编辑库区下库位信息
export function putStorehouseAreaPlat(data) {
  return request({
    url: '/basic/storehouseAreaPlat',
    method: 'put',
    data
  })
}
// 上传库区图片的接口
export function uploadStoreHouseArea(data) {
  return request({
    url: '/basic/storehouseAreaPlat/uploadStoreHouseArea',
    method: 'put',
    data
  })
}